package com.woniu.rear.comm.web.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * servletAPI工具类
 * @author liwei
 *
 */
public class ServletUtil {
	
	public static HttpServletRequest getRequest() {
		ServletRequestAttributes sra = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
		return sra.getRequest();
	}
	
	public static HttpServletResponse getResponse() {
		ServletRequestAttributes sra = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
		return sra.getResponse();
	}
	
	public static HttpSession getSession() {
		ServletRequestAttributes sra = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
		return sra.getRequest().getSession();
	}

}
